﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LockCrypt.Core {
    /// <summary>
    /// Manages generic settings in LockCrypt
    /// </summary>
    public static class CoreConfigurationManager {
        public static string Language { get; set; }

        public static void Configure(ICoreConfiguration configuration) {
            Language = configuration.Language;
        }

        /// <summary>
        /// Gets an encryption provider for an encryption type.
        /// </summary>
        /// <param name="providerType">The type of encryption.</param>
        /// <param name="key">The key.</param>
        /// <returns>An appropriate provider, or a dummy service.</returns>
        public static IEncryptionService GetEncryptionProvider(EncryptionProviders providerType, string key) {
            IEncryptionService encryption;
            try {
                switch (providerType) {
                    case EncryptionProviders.Aes256:
                        encryption = new Aes256EncryptionService(key);
                        break;
                    case EncryptionProviders.TwoFish256:
                        encryption = new TwoFishEncryptionService(key);
                        break;
                    case EncryptionProviders.None:
                    default:
                        encryption = new NullEncryptionService();
                        break;
                }
            } catch {
                encryption = new NullEncryptionService();
            }
            return encryption;
        }
    }

    public interface ICoreConfiguration {
        string Language { get; set; }
    }
}
